package com.yxh.controller;

import com.wordnik.swagger.annotations.ApiImplicitParam;
import com.wordnik.swagger.annotations.ApiImplicitParams;
import com.yxh.common.annotation.Authorization;
import com.yxh.service.TaskHistroyService;
import com.yxh.util.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.*;

import static com.yxh.util.APIErrorCode.DELETE_ERROR;
import static com.yxh.util.APIErrorCode.SUCCESS;

/**
 * Created by asus on 2018/6/7.
 */

@Scope("prototype")
@RestController
@RequestMapping(value = "/history")
public class TaskHistroyController extends BaseController{

    private static final Logger logger = LoggerFactory.getLogger(TaskHistroyController.class);
    private Response response;

    @Autowired
    private TaskHistroyService taskHistroyService;

    @GetMapping("/{id}")
    @Authorization
    @ApiImplicitParams({
            @ApiImplicitParam(name = "authorization", value = "authorization", required = true, dataType = "string", paramType = "header"),
    })
    public Response removeDept(@PathVariable("id") String id) {
        response = Response.returnResponse(SUCCESS);
        response.setData(taskHistroyService.getHistrot(id));
        return response;
    }

    @GetMapping("/vicious/{id}")
    @Authorization
    @ApiImplicitParams({
            @ApiImplicitParam(name = "authorization", value = "authorization", required = true, dataType = "string", paramType = "header"),
    })
    public Response vicious(@PathVariable("id") Integer id) {
        response = Response.returnResponse(SUCCESS);
        response.setData(taskHistroyService.get(id));
        return response;
    }


}
